<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>隐私设置</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f8f9fa;
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            overflow: hidden;
            border: 3px solid;
            border-color: var(--theme-rose, #df0e62);
            border-image: none;
        }

        .header {
            background: #fff;
            color: #222;
            padding: 30px;
            text-align: center;
            border-bottom: 1px solid #e1e5e9;
        }

        .header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
            font-weight: 300;
        }

        .header p {
            opacity: 0.9;
            font-size: 1.1em;
        }

        .content {
            padding: 40px;
        }

        .section {
            margin-bottom: 40px;
            padding: 30px;
            background: #f8f9fa;
            border-radius: 15px;
            border-left: 5px solid #e1e5e9;
        }

        .section h2 {
            color: #333;
            margin-bottom: 20px;
            font-size: 1.5em;
            display: flex;
            align-items: center;
        }

        .section h2::before {
            content: "🔒";
            margin-right: 10px;
            font-size: 1.2em;
        }

        .form-group {
            margin-bottom: 25px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: 500;
            font-size: 1.1em;
        }

        .form-control {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #e1e5e9;
            border-radius: 10px;
            font-size: 1em;
            transition: all 0.3s ease;
            background: white;
        }

        .form-control:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .btn, .btn-primary, .btn-success {
            background: var(--theme-rose, #df0e62) !important;
            color: #fff !important;
            border: none;
            padding: 15px 30px;
            border-radius: 10px;
            font-size: 1.1em;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
            margin: 10px 10px 10px 0;
        }

        .btn:hover, .btn-primary:hover, .btn-success:hover {
            opacity: 0.92;
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(223,14,98,0.13);
        }

        .btn-secondary {
            background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
        }

        .btn-secondary:hover {
            box-shadow: 0 10px 20px rgba(108, 117, 125, 0.3);
        }

        .status-indicator {
            display: inline-block;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            margin-right: 8px;
        }

        .status-online { background: #28a745; }
        .status-offline { background: #6c757d; }
        .status-invisible { background: #ffc107; }

        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .feature-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            border: 1px solid #e1e5e9;
            text-align: center;
            transition: all 0.3s ease;
        }

        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }

        .feature-icon {
            font-size: 2em;
            margin-bottom: 10px;
        }

        .feature-title {
            font-weight: 600;
            color: #333;
            margin-bottom: 8px;
        }

        .feature-desc {
            color: #666;
            font-size: 0.9em;
            line-height: 1.4;
        }

        .alert {
            padding: 15px;
            border-radius: 10px;
            margin-bottom: 20px;
            display: none;
        }

        .alert-success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .alert-error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        @media (max-width: 768px) {
            .container {
                margin: 10px;
                border-radius: 15px;
            }
            
            .content {
                padding: 20px;
            }
            
            .header h1 {
                font-size: 2em;
            }
            
            .feature-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>隐私设置</h1>
            <p>管理您的隐私偏好和屏蔽关系</p>
        </div>
        
        <div class="content">
            <div id="alert" class="alert"></div>
            
            <div class="section">
                <h2>在线状态设置</h2>
                <div class="form-group">
                    <label for="onlineStatus">当前状态：</label>
                    <select name="onlineStatus" id="onlineStatus" class="form-control">
                        <option value="1">
                            <span class="status-indicator status-online"></span>在线
                        </option>
                        <option value="0">
                            <span class="status-indicator status-offline"></span>离线
                        </option>
                        <option value="2">
                            <span class="status-indicator status-invisible"></span>隐身
                        </option>
                    </select>
                </div>
                
                <div class="form-group">
                    <label for="strangerViewVideos">陌生人可见性：</label>
                    <select name="strangerViewVideos" id="strangerViewVideos" class="form-control">
                        <option value="1">允许陌生人查看我的视频</option>
                        <option value="0">仅好友可查看我的视频</option>
                    </select>
                </div>
                
                <button type="button" class="btn" onclick="savePrivacy()">
                    💾 保存设置
                </button>
            </div>

            <div class="section">
                <h2>屏蔽管理</h2>
                <p style="color: #666; margin-bottom: 20px;">
                    管理您不想看到的用户和不想让谁看到您的内容
                </p>
                
                <div class="feature-grid">
                    <div class="feature-card">
                        <div class="feature-icon">🚫</div>
                        <div class="feature-title">不看TA</div>
                        <div class="feature-desc">屏蔽指定用户的视频，不再看到他们的内容</div>
                    </div>
                    
                    <div class="feature-card">
                        <div class="feature-icon">👁️</div>
                        <div class="feature-title">不让TA看我</div>
                        <div class="feature-desc">禁止指定用户查看您发布的视频</div>
                    </div>
                    
                    <div class="feature-card">
                        <div class="feature-icon">🔒</div>
                        <div class="feature-title">全部屏蔽</div>
                        <div class="feature-desc">双向屏蔽，既不看TA也不让TA看您</div>
                    </div>
                </div>
                
                <a href="/block_manage" class="btn btn-secondary">
                    ⚙️ 管理屏蔽关系
                </a>
            </div>

            <div class="section">
                <h2>隐私说明</h2>
                <ul style="color: #666; line-height: 1.6; padding-left: 20px;">
                    <li>在线状态：控制其他用户是否能看到您的在线状态</li>
                    <li>陌生人可见性：控制非好友用户是否能查看您发布的视频</li>
                    <li>屏蔽功能：可以屏蔽特定用户，避免看到不想看的内容</li>
                    <li>所有设置都会实时生效，保护您的隐私安全</li>
                </ul>
            </div>
        </div>
    </div>

    <script>
        function showAlert(message, type) {
            const alert = document.getElementById('alert');
            alert.textContent = message;
            alert.className = `alert alert-${type}`;
            alert.style.display = 'block';
            
            setTimeout(() => {
                alert.style.display = 'none';
            }, 3000);
        }

        function savePrivacy() {
            const data = {
                userId: /*[[${session.user.userId}]]*/ 1,
                onlineStatus: parseInt(document.getElementById('onlineStatus').value),
                strangerViewVideos: parseInt(document.getElementById('strangerViewVideos').value)
            };
            
            fetch('/api/privacy/update', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(data)
            })
            .then(response => response.text())
            .then(result => {
                if (result === 'success') {
                    showAlert('隐私设置保存成功！', 'success');
                } else {
                    showAlert('保存失败：' + result, 'error');
                }
            })
            .catch(error => {
                showAlert('保存失败，请稍后重试', 'error');
                console.error('Error:', error);
            });
        }

        // 页面加载时获取当前设置
        window.onload = function() {
            const userId = /*[[${session.user.userId}]]*/ 1;
            fetch('/api/privacy/' + userId)
                .then(response => response.json())
                .then(settings => {
                    if (settings) {
                        document.getElementById('onlineStatus').value = settings.onlineStatus || 1;
                        document.getElementById('strangerViewVideos').value = settings.strangerViewVideos || 1;
                    }
                })
                .catch(error => {
                    console.log('未找到隐私设置，使用默认值');
                });
        };
    </script>
</body>
</html> 